version: "3.7"
services:
    e-campus-postgres:
        container_name: e-campus-postgres
        image: postgres
        restart: always
        environment:
            - POSTGRES_DB=${POSTGRES_DB}
            - POSTGRES_USER=${POSTGRES_USER}
            - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
        volumes:
            - e-campus-postgres-data:/var/lib/postgresql/data
        ports:
            - "54322:5432"

    e-campus-pgadmin:
        image: dpage/pgadmin4
        container_name: e-campus-pgadmin
        restart: always
        depends_on:
            - e-campus-postgres
        ports:
            - "5080:80"
        environment:
            - PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL}
            - PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD}
        volumes:
            - e-campus-pgadmin-data:/var/lib/pgadmin

    e-campus-minio:
        container_name: e-campus-minio
        image: quay.io/minio/minio
        restart: always
        ports:
            - "9090:9000"
            - "9091:9001"
        volumes:
            - e-campus-minio-data:/data
        environment:
            - MINIO_ROOT_USER=${MINIO_ROOT_USER}
            - MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}
        command: server /data --console-address ":9001"

    e-campus-minio-create-buckets:
        image: minio/mc
        depends_on:
            - e-campus-minio
        entrypoint: >
            /bin/sh -c "
            /usr/bin/mc alias set e_campus_minio http://e-campus-minio:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD};
            /usr/bin/mc mb e_campus_minio/public;
            /usr/bin/mc anonymous set download e_campus_minio/public;
            /usr/bin/mc mb e_campus_minio/private;
            exit 0;
            "

volumes:
    e-campus-postgres-data:
    e-campus-minio-data:
    e-campus-pgadmin-data:
